package com.tanhua.server.intercepror;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig  implements WebMvcConfigurer {

    /**
     * 拦截器：判断是否登录的。
     *     发送登录验证码  /user/login
     *     通过验证码登录  /user/loginVerification
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TokenInterceptor())
                .addPathPatterns("/**")  //指定拦截器处理的URL
                .excludePathPatterns(new String[]{"/user/login","/user/loginVerification"});  //指定拦截器不处理的URL
    }
}